package com.itheima;

public class Test5 {
    public static void main(String[] args) {
        //拷贝数组
        int[] arr = {1, 2, 3};
        int[] arr2 = copyArray(arr);
        printArry(arr2);

    }

    public static void printArry(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(i == arr.length - 1 ? arr[i] : arr[i] + ", ");
        }
        System.out.println("]");
    }

    public static int[] copyArray(int[] arr) {
        int[] arr2 = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            arr2[i] = arr[i];
        }
        return arr2;

    }
}
